package com.julian.delegatePattern.gumballMachine.client;

import com.julian.delegatePattern.gumballMachine.GumballMachineRemote;

import java.rmi.Naming;

public class GumballMonitorTestDrive {

    public static void main(String[] args) {
        String[] location = {"rmi://127.0.0.1:1902/gumballMachineRemote",
                             "rmi://127.0.0.1:1902/gumballMachineRemote",
                             "rmi://127.0.0.1:1902/gumballMachineRemote"};
        GumballMonitor[] monitors = new GumballMonitor[location.length];
        for (int i = 0; i < location.length; i++){
            try{
                GumballMachineRemote gumballMachineRemote = (GumballMachineRemote) Naming.lookup(location[i]);
                monitors[i] = new GumballMonitor(gumballMachineRemote);
                System.out.println(monitors[i]);
            }catch (Exception e){
                e.printStackTrace();
            }
        }

        for (int i = 0; i < monitors.length; i++){
            monitors[i].report();
        }


    }
}
